package TestCases;

import junit.framework.TestCase;
import Tracer.RTColor;

/**
 * 
 */

/**
 * @author Lu Liu
 * 
 */
public class RTColorTest extends TestCase {

	private RTColor color1;
	private RTColor color2;

	protected void setUp() throws Exception {
		super.setUp();
		color1 = new RTColor(102, 204, 0);
		color2 = new RTColor(1.0f, 0.0f, 0.1f);
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	/**
	 * Test method for getRed Test it works well after performing getRed
	 */
	public void testGetRed() {
		int red1 = color1.getRed();
		assertEquals("GetRed Method is not correct!", 102, red1);
	}

	/**
	 * Test method for getGreen Test it works well after performing getGreen
	 */
	public void testGetGreen() {
		int green1 = color1.getGreen();
		assertEquals("GetGreen Method is not correct!", 204, green1);
	}

	/**
	 * Test method for getBlue Test it works well after performing getBlue
	 */
	public void testGetBlue() {
		int blue1 = color1.getBlue();
		assertEquals("GetBlue Method is not correct!", 0, blue1);

	}

	/**
	 * Test method for getRedf Test it works well after performing getRedf
	 */
	public void testGetRedF() {
		float red1 = color2.getRedf();
		assertEquals("GetRedf Method is not correct!", 1.0f, red1);
	}

	/**
	 * Test method for getGreenf Test it works well after performing getGreenf
	 */
	public void testGetGreenF() {
		float green1 = color2.getGreenf();
		assertEquals("GetGreenf Method is not correct!", 0.0f, green1);
	}

	/**
	 * Test method for getBluef Test it works well after performing getBluef
	 */
	public void testGetBlueF() {
		float blue1 = color2.getBluef();
		assertEquals("GetBluef Method is not correct!", 0.09803922f, blue1);

	}

	/**
	 * Test method for IsEqua Test it works well after performing IsEqua
	 */
	public void testIsEqual() {
		RTColor c1 = new RTColor(102, 102, 102);
		RTColor c2 = new RTColor(102, 102, 102);
		assertEquals("Equal colors are determined to be unequal", true, c1
				.isEqual(c2));

	}

	/**
	 * Test method for multByNumber Test it works well after performing
	 * multByNumber
	 */
	public void multByNumber() {
		RTColor color5 = RTColor.multByNumber(color1, 0.5);
		assertEquals("Red color value incorrect from int int int", 51, color5
				.getRed());
		assertEquals("Green color value incorrect from int int int", 102,
				color5.getGreen());
		assertEquals("Blue color value incorrect from int int int", 0, color5
				.getBlue());
	}
}
